package com.opencvjava.lessons.imgproc;

import org.opencv.core.Mat;
import org.opencv.core.Size;
import org.opencv.imgproc.Imgproc;
import org.springframework.stereotype.Service;

import static com.opencvjava.support.util.CvUtils.imshow;
import static com.opencvjava.support.util.CvUtils.mat;
import static org.opencv.imgproc.Imgproc.pyrDown;
import static org.opencv.imgproc.Imgproc.pyrUp;

@Service
public class L8_ImagePyramids {
    public void test() {
        Mat src = mat("lena.jpg");
        // Check if image is loaded fine
        if (src.empty()) {
            throw new RuntimeException("读取图片失败");
        }
        imshow("Pyramids Demo", src);
        Mat dst = new Mat();
        pyrUp(src, dst, new Size(src.cols() * 2, src.rows() * 2));
        imshow("pyrUp", dst);
        pyrDown(src, dst, new Size(src.cols() / 2, src.rows() / 2));
        imshow("pyrDown", dst);
    }
}
